package com.evil.application.pojo.dto.robot;

import com.evil.application.pojo.entity.ApplicationRobot;
import com.evil.common.application.dto.robot.RobotSourceDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

/**
 * 新增机器人信息 请求实体
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class AddRobotReqDTO extends ApplicationRobotDTO {

    @NotNull(message = "source not null")
    private RobotSourceDTO source;

    private Long enterpriseId;

    public AddRobotReqDTO(ApplicationRobot applicationRobot) {
        super(applicationRobot);
    }

    public ApplicationRobot toApplicationRobot() {
        ApplicationRobot robot = new ApplicationRobot();
        this.copyProp(robot);
        robot.setSourceType(source.getSourceType());
        robot.setSourceId(source.getSourceId());
        robot.setApplicationVersion(this.source.getVersion());
        return robot;
    }
}
